<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>修改</title>
    <link rel="stylesheet" href="../layui/css/layui.css"/>
    <link rel="stylesheet" href="../css/admin.css"/>
    <style>
      .layui-form{
      width: 350px;
      height:80px;
      margin:0 auto;
      }
      .add-name th{
        width:100px;
        height:40px;
        font-size:14px;
        padding: 0;
        vertical-align: middle;
      }
      .add-name input{
        outline:none;
        width:160px;
        height: 28px;
        border:1px solid #E5BA70;
        border-radius:5px;
      }
      .tianjia-checkBox th{
        width:100px;
        height:40px;
        font-size:14px;
        padding: 0;
        vertical-align: middle;
      }
      tr.tianjia-checkBox td input{
        display: inline-block;
      }
      .layui-form .layui-table{
        margin-top:50px;
        margin:0 auto;
      }
     .layui-input-block  span{
      font-size: 14px;
    }
    .layui-input-block th{
       font-size: 14px;
    }
    #btn-c,#btn-s{
      border:0;
      margin-top: 3px;
      width: 100px;
      height: 28px;
      border-radius:5px;
      background-color: #D8D8D8;
    }
    #btn-c{
       margin-left:70px;
    }
    #btn-s:hover,#btn-c:hover{
     background-color:#EF7632;
    }
    #btn-s{
        margin-left:15px;
    }
    .layui-layer .layui-layer-title{
      background-color: #fff;
    }
    .layui-form-radio{
      padding:0;
    }
    </style>
</head>
<body>
     <form class="layui-form" action="">
          <table class="layui-table layui-table-add" lay-skin="nob">
          <tbody>
             <tr class="add-name">
  <th>楼&nbsp;&nbsp;层</th>
  <td><input type="text" id="loucen" value=""  onfocus="this.style.color='#777';"  onblur="this.style.color='#777'; this.value=this.value"/></td>
</tr>
            <tr class="add-name">
              <th>门&nbsp;牌&nbsp;号</th>
              <td><input type="text" id="menpaihao" value=""  onfocus="this.style.color='#777';"  onblur="this.style.color='#777'; this.value=this.value"/></td>
            </tr>
            <tr class="add-name">
              <th>用户账号</th>
              <td><input type="text" id="user_tel"  value=""  onfocus="this.style.color='#777';   this.value='';"  onblur="this.style.color='#777';  this.value=this.value"/></td>
            </tr>
            <tr class="add-name">
              <th >账户余额</th>
              <td><input type="text" id="balance" value="" onfocus="this.style.color='#777';
       this.value='';"  onblur="this.style.color='#777';  this.value=this.value" /></td>
            </tr>
          </tbody>
        </table>
         <input type="button" id="btn-c" value="取消">
          <input type="button" id="btn-s" value="保存">
      </form>
  <script type="text/javascript" src="../layui/layui.js"></script>
  <script>
    layui.use(['jquery','form','upload','layer'], function(){
            var $ = layui.jquery,layer = layui.layer;

      $("#btn-s").off("click","#btn-s").on("click",function(){
        var loucen = $("#loucen").val();
        var menpaihao = $("#menpaihao").val();
        var user_tel = $("#user_tel").val();
        var balance = $("#balance").val();
            parseInt(balance);
        var user_id =localStorage.getItem("userId");
            console.log(user_id);

       console.log(loucen);
       console.log(menpaihao);
       console.log(user_tel);
       console.log(balance);
       if(loucen &&menpaihao&&user_tel&&balance){
         $.ajax({
           url: '../../organization_manage/updateUser',
           type: 'POST',
           dataType: "json",
           data: {
                user_id:user_id,
                loucen:loucen,
                menpaihao:menpaihao,
                user_tel:user_tel,
                balance:balance
          },
            success: function(response){
                console.log("success",response);
                alert("修改成功！")
                window.parent.location.reload();
                var index=parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
             if(response.resultCode =='200'){
                 console.log("inputUsersuccess");

            }
          },
         error:function(response){
              console.log("fail",response);
             alert("修改失败！")
             window.parent.location.reload();
             var index=parent.layer.getFrameIndex(window.name);
             parent.layer.close(index);
              if(response.resultCode=='001'){
                console.log("param is not found")
                }else if(response.resultCode=='009'){
                  console.log("param is not found")
                }else if(response.resultCode=='002'){
                  console.log("Phone number is not vaild")
                }else if(response.resultCode=='012'){
                  console.log("String is not money")
                }
            }
        })
      }

    })
   $("#btn-c").click(function(){
        window.parent.location.reload();
        var index=parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
     })
        });

  </script>
</body>
</html>
